package com.sntra.beibi.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sntra.beibi.dao.BookMapper;
import com.sntra.beibi.dao.PageMapper;
import com.sntra.beibi.domain.Book;
import com.sntra.beibi.domain.Page;
import com.sntra.beibi.service.BookService;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookMapper bookMapper;
    
    @Autowired
    private PageMapper pageMapper;

    @Override
    public boolean updateBookMsg(Book book) {
        return bookMapper.updateBookMsg(book) >0 ?true:false;
    }

    @Override
    public boolean deleteBook(Integer id) {
        return bookMapper.deleteBook(id) >0 ?true:false;
    }

    @Override
    public List<Book> allBook()
    {
        return bookMapper.allBook();
    }

    @Override
    public List<Book> likeTitle(String title)
    {
        return bookMapper.likeTitle(title);
    }

    @Override
    public List<Book> bookOfTitle(String title)
    {
        return bookMapper.bookOfTitle(title);
    }

    @Override
    public boolean addBook(Book book)
    {
        return bookMapper.insertSelective(book) > 0?true:false;
    }

    @Override
    public boolean updateBookImg(Book book) {

        return bookMapper.updateBookImg(book) >0 ?true:false;
    }

	@Override
	public Page selectPage(Page page) {
		// TODO Auto-generated method stub
		return pageMapper.selectPageByBookIdAndPageNo(page.getBookId(), page.getPageNo());
	}

	@Override
	public int updateImgStatus(Page page) {
		// TODO Auto-generated method stub
		return pageMapper.updateImgStatus(page);
	}
}
